/**
 * @file:          Svpwm.h
 * @brief:
 * @details:
 * @author:        wjh
 * @date created:  2025.07.06
 * @version:       1.0.0
 * @par copyright (c):
 *
 * @par history (desc):
 *   version:1.0.0, wjh, 2025.07.06,17:39:58
 */

#ifndef _SVPWM_H_
#define _SVPWM_H_

/* Include Files **************************************************************/
#include <math.h>
#include "base_math.h"
#include "Datatype.h"

/* Macro Definition ***********************************************************/
static const uint8_t N2Section[7] = {0, 2, 6, 1, 4, 3, 5};

/* Data Type Define ***********************************************************/
typedef struct Svpwm
{
    /* public data */
    float param_Udc;
    float param_Ts;
    float in_ualpha;
    float in_ubeta;

    float Ux;
    float Uy;
    float Uz;

    float Tx;
    float Ty;
    float Tz;

    float Ta; 
    float Tb; 
    float Tc; 
    
    float T0;
    float T1;
    float T2;

    float T0_sat;
    float T1_sat;
    float T2_sat;
    
    float out_Tcm1;
    float out_Tcm2;
    float out_Tcm3;

    uint8_t N;
    uint8_t sector;

    /* private data */

    /* public method */
    void (*Init)(struct Svpwm *self);
    void (*Run)(struct Svpwm *self);

    /* private method */

} Svpwm;

/* Variable Declare ***********************************************************/

/* Function Declare ***********************************************************/
void Svpwm_Init(struct Svpwm *self);
void Svpwm_Run_7Segment(struct Svpwm *self);

#endif